﻿@{
    ViewBag.Title = "用户管理";
    Layout = "~/Views/Shared/_ListLayout.cshtml";
}
@inherits CMSWebViewPage<object>
@section Head{

}
<div id="toolbar_userinfo" class="datagrid-toolbar">
    @CurrentButtonTool.Create()
    <div>
        <form id="fr_search_userinfo" method="post">
            @Html.QueryStringBox("用户名称", "UserName")
            @Html.QueryStringBox("真实姓名", "RealName")
            @Html.QueryDateTimeBox("创建时间", "CreateDate")-@Html.QueryDateTimeBox("", "CreateDate", QueryMethod.LessEqual, QueryDataType.DateTime)
            <a onclick="Search();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true"></a>
        </form>
    </div>
</div>
<table id="dg_userinfo" data-options="url:'/userinfo/listjson/',border:false,fit:true,fitColumns:true,toolbar:'#toolbar_userinfo',singleSelect:true,pagination:true,pageSize:20">
    <thead>
        <tr>
            <th data-options="field:'ck',checkbox:true"></th>
            <th data-options="field:'Id',width:30,align:'center'">主键</th>
            <th data-options="field:'UserName',width:50,align:'center'">用户名称</th>
            <th data-options="field:'RealName',width:50,align:'center'">真实姓名</th>
            <th data-options="field:'PowerType',width:50,formatter:FormatPowerType,align:'center'">权限类型</th>
            <th data-options="field:'Sex',width:30,formatter:FormatSex,align:'center'">性别</th>
            <th data-options="field:'Telephone',width:50,align:'center'">手机号</th>
            <th data-options="field:'LoginIP',width:50,align:'center'">登录IP</th>
            <th data-options="field:'LoginDate',width:80,formatter:JsonToDate,align:'center'">登录时间</th>
            <th data-options="field:'CreateDate',width:80,formatter:JsonToDate,align:'center'">创建时间</th>
        </tr>
    </thead>
</table>
@section Bottom{
    <script type="text/javascript">
        var objBizDatagrid = new BizDatagrid('#dg_userinfo');
        function Add() {
            objBizDatagrid.add("/userinfo/editpage");
        }
        function SyncRedis() {
            var objRow = objBizDatagrid.selectRow();
            var objAjaxEntity = new AjaxEntity();
            objAjaxEntity.url = "/UserInfo/SyncRedis/" + objRow.Id;
            objAjaxEntity.executing = function () {
                ShowProcess();
                return true;
            };
            objAjaxEntity.executeSuccess = function (invokeresult) {
                ShowMessage(invokeresult.ResultMessage);
                CloseProcess();
            };
            objAjaxEntity.execute();
        }
        function EditUserPowerInfo() {
            var objRow = objBizDatagrid.selectRow();
            window.location.href = "/groupinfo/edituserpowerinfo?TransferID=" + objRow.Id + "&UserName=" + objRow.UserName;
        }
        function EditUserDependentPowerInfo() {
            var objRow = objBizDatagrid.selectRow();
            window.location.href = "/groupinfo/edituserdependentpowerinfo?TransferID=" + objRow.Id + "&UserName=" + objRow.UserName;
        }
        function ViewUserPowerInfo() {
            var objRow = objBizDatagrid.selectRow();
            window.location.href = "/groupinfo/viewuserpowerinfo?TransferID=" + objRow.Id;
        }
        function Edit() {
            objBizDatagrid.edit("/userinfo/editpage");
        }
        function Search() {
            objBizDatagrid.search('#fr_search_userinfo', '/userinfo/listjson');
        }
        function Delete() {
            objBizDatagrid.del('/userinfo/delete');
        }
        function FormatPowerType(val, row) {
            var result = "";
            switch (val) {
                case 0:
                    result = "继承角色组部分权限";
                    break;
                case 1:
                    result = "继承角色组所有权限";
                    break;
                case 2:
                    result = "用户独立权限";
                    break;
            }
            return result;
        }
        function FormatSex(val, row) {
            var result = "";
            switch (val) {
                case 0:
                    result = "男";
                    break;
                case 1:
                    result = "女";
                    break;
            }
            return result;
        }
        function Export() {
            //var options = objBizDatagrid.source.datagrid('getPager').data("pagination").options;
            //var curr = options.pageNumber;
            //var total = options.total;
            //var max = Math.ceil(total / options.pageSize);
            //TransferToUrl("/UserInfo/Export");

            //var objFormEntity = new FormEntity("#fr_search_userinfo");
            //objFormEntity.url = "/UserInfo/Export";
            //objFormEntity.handle = function () {
            //    var $this = this;
            //    this.source.form('submit', { url: $this.url });
            //}
            //objFormEntity.submit();

            objBizDatagrid.export('#fr_search_userinfo', '/UserInfo/Export');
        }
    </script>
}
